package swordoffer.offer50;

import java.util.HashMap;
import java.util.Map;

public class HashSolution {
    public char firstUniqChar(String s) {
        Map<Character, Boolean> dic = new HashMap<>();
        for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            if (!dic.containsKey(ch)) {
                dic.put(ch, true);
            } else {
                dic.put(ch, false);
            }
        }
        for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            if (dic.get(ch)) {
                return ch;
            }
        }
        return ' ';
    }
}
